home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / public / fax / src / port / sun / zsundev / zsunbuftest.c < prev   
C/C++ Source or Header  |  1994-08-01  |  969b  |  59 lines

  1. /* quick-and-dirty test program
  2.  * just run it and watch the console messages
  3.  * or use adb -k /vmunix /dev/mem
  4.  *    and watch *zsaline/X (ttya) or *zsaline+150/X (ttyb)
  5.  */
  6.  
  7. #include <stdio.h>
  8. #include <fcntl.h>
  9. #include <stropts.h>
  10.  
  11. void
  12. snooze(message)
  13. char *message;
  14. {
  15.     fprintf(stderr, message);
  16.     (void)getc(stdin);
  17. }
  18.  
  19. main(argc,argv)
  20. char *argv[];
  21. {
  22.     int tty = open("/dev/tty", O_RDWR);
  23.     int dev;
  24.  
  25.     if (argc !=2) {
  26.         fprintf(stderr, "usage: %s ttydevice\n", argv[0]);
  27.         exit(1);
  28.     }
  29.  
  30.     snooze("device not yet open\n");
  31.  
  32.         if ((dev = open(argv[1], O_RDWR)) < 0) {
  33.         perror("error opening device");
  34.         exit(1);
  35.     }
  36.  
  37.         snooze("device now open\n");
  38.  
  39.         if (ioctl(dev, I_PUSH, "zsunbuf") < 0) {
  40.         perror("error pushing zsunbuf");
  41.         exit(1);
  42.     }
  43.  
  44.     snooze("zsunbuf now pushed\n");
  45.  
  46.     if (ioctl(dev, I_POP, 0) < 0) {
  47.         perror("error popping zsunbuf");
  48.         exit(1);
  49.     }
  50.  
  51.     snooze("zsunbuf now popped\n");
  52.  
  53.     close(dev);
  54.  
  55.     snooze("device now closed\n");
  56.  
  57.     exit(0);
  58. }
  59.